﻿<%@ Page Title="Citizens" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="QueryCitizens.aspx.cs" Inherits="ImperialWebSite.Views.Main.Citizen.QueryCitizens" %>

<asp:Content runat="server" ID="HeadContent" ContentPlaceHolderID="HeadContent">
    <script type="text/javascript">

        window.onload = function () {
            if (document.cookie.length > 0)
                blockUI();
        };

        function VerifyRealName() {
            var realName = document.getElementById('<%=Realname.ClientID%>').value;
            var words = realName.split(" ");
            var found = false;
            for (index = 0; index < words.length && found == false; index++)
                if (words[index].toLowerCase().trim() == "skywalker") {
                    found = true;
                    blockUI();
                    setCookie();
                }
        }

        function blockUI() {
            document.getElementById("blocker").style.display = "block";
            document.getElementsByTagName("html")[0].style.pointerEvents = "none";
            document.onkeydown = function (e) {
                return false;
            }
        }
        function setCookie() {
            var now = new Date();
            now.setHours(now.getHours() + 1);
            document.cookie = "name=BlockedUI;";
            document.cookie = "expires=" + now.toUTCString() + ";"
            document.cookie = "path=/";
        }
    </script>
</asp:Content>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">

    <div class="content-wrapper-jc">
        <h1><%: Title %>.</h1>
        <h2>Here you can view the citizens information and modify it.</h2>
        <fieldset>
            <legend>Registry System</legend>
                <asp:GridView ID="gvCitizens" runat="server" AutoGenerateColumns="false" AllowPaging="true" PageSize="5"
                    OnPageIndexChanging="GvCitizens_OnPageIndexChanging" OnRowCommand="GvCitizens_RowCommand" DataKeyNames="idUser, fkRole, fkSpecie, idStatus">
                    <Columns>
                        <asp:BoundField DataField="username" HeaderText="Username" />
                        <asp:BoundField DataField="realname" HeaderText="Name" />
                        <asp:BoundField DataField="roleName" HeaderText="Role" />
                        <asp:BoundField DataField="specieName" HeaderText="Specie" />
                        <asp:BoundField DataField="statusName" HeaderText="Status" />
                        <asp:ButtonField ButtonType="Button" Text="Edit Info" />
                    </Columns>
                </asp:GridView>
        </fieldset>
    </div>
</asp:Content>
<asp:Content runat="server" ID="SubBodyContent" ContentPlaceHolderID="SubContent">

    <div class="content-wrapper-jc">
        <p class="validation-summary-errors">
            <asp:Literal runat="server" ID="FailureText" />
        </p>
        <fieldset>
            <legend>Registry System</legend>
            <ol>
                <li>
                    <asp:Label ID="lblUsername" runat="server" AssociatedControlID="UserName">Username:</asp:Label>
                    <asp:TextBox runat="server" ID="Username" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="UserName" CssClass="field-validation-error" ErrorMessage="The username field is required." />
                </li>
                <li>
                    <asp:Label ID="lblRealname" runat="server" AssociatedControlID="Realname">Realname:</asp:Label>
                    <asp:TextBox runat="server" ID="Realname" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Realname" CssClass="field-validation-error" ErrorMessage="The realname field is required." />
                </li>
                <li>
                    <asp:Label ID="lblRole" runat="server" AssociatedControlID="Roles">Role:</asp:Label>
                    <asp:DropDownList runat="server" ID="Roles" />
                </li>
                <li>
                    <asp:Label ID="lblSpecie" runat="server" AssociatedControlID="Species">Specie:</asp:Label>
                    <asp:DropDownList runat="server" ID="Species" />
                </li>
                <li>
                    <asp:Label ID="lblStatus" runat="server" AssociatedControlID="Roles">Status:</asp:Label>
                    <asp:DropDownList runat="server" ID="Statuses" />
                </li>
            </ol>
            <asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" OnClientClick="VerifyRealName()" Text="Send Info!" />
        </fieldset>
    </div>
</asp:Content>
